package com.ihr360.binlog.listener;


import com.ihr360.binlog.component.BinlogReceiverStarter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

import java.util.logging.Logger;


/**
 * Created by davidwei on 17-8-2.
 */
@Component
public class ApplicationStartupListener {
    Logger logger = Logger.getLogger(ApplicationStartupListener.class.getName());


    @Value("${ihr360.datasource.autoup.afterstart:true}")
    private Boolean autoUp;

    @Autowired
    private BinlogReceiverStarter receiverStarter;

    @EventListener(ApplicationReadyEvent.class)
    public void startBinLogReceiver() {
        if (autoUp) {
            receiverStarter.startAll();
        }
    }
}
